import { defineStore } from "pinia";
import { get, post } from "@/utils/request";
import {ref} from 'vue'

export const useMentorUser = defineStore('mUser',() => {
  // 个人中心页信息
  let mUserData = ref(null)
  const mUserRequest = async () => {
    try {
      const response = await get('/teacher/info')
      mUserData.value = response.data
    } catch (error) {
      console.error(error)
    }
  }

  // 个人中心重置页面
  const mUChangePassword = async (changePassword) => {
    try {
      const response = await post('/teacher/resetPassword',{
        oldPassword:changePassword.oldPassword,
        newPassword:changePassword.newPassword
      })
    } catch (error) {
      console.error(error)
    }
  }


  return {mUserData,mUserRequest,mUChangePassword}
})